package com.lubase.wfengine;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class RedisTestDemo {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    CacheManager cacheManager;

    @Test
    void testRedisList() {
        redisTemplate.opsForList().leftPush("wfengine:abc:dataid1", "1");
        redisTemplate.opsForList().leftPush("wfengine:abc:dataid1", "2");
        redisTemplate.opsForList().leftPush("wfengine:abc:dataid1", "3");
        redisTemplate.opsForList().leftPush("a::b:c", 12313);
    }

    @Test
    void testRedisHash() {
        Cache cache = cacheManager.getCache("wfengine");
        List<String> arrary = new ArrayList<>();
        arrary.add("1");
        arrary.add("2");
        cache.put("aaa:b:e", arrary);
        List<String> list = cache.get("aaa:b:e", List.class);
        System.out.println(list);
    }
}
